package com.ccys.cms.controller.corporateAndInsurance;

import com.ccys.cms.service.corporateAndInsurance.EapService;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.corporateAndInsurance.EapBenefitAdjustmentDto;
import com.ccys.db.dto.corporateAndInsurance.EapBenefitDto;
import com.ccys.db.dto.corporateAndInsurance.EapBenefitServiceDto;
import com.ccys.db.dto.corporateAndInsurance.EapDto;
import com.ccys.db.vo.corporateAndInsurance.*;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.text.ParseException;
import java.util.List;

/**
 * @program: WhiteCoat
 * @description: EAP接口
 * @author: ZhangJingCan
 * @create: 2023-12-22 15:52
 **/

@RestController
@RequestMapping("/eap")
@Api(tags = "EAP接口")
public class EapController {

    @Autowired
    private EapService eapService;


    @PostMapping("saveEap")
    @ApiOperation("保存EAP(只允许新增，不提供修改)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "0-retail;1-AIA corporate;2-AIA healthshield;3-Direct corporate;4-Subscription", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "planId", value = "retail 与AIA healthshield 不需要传值", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "benefitId", value = "benefitId", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult saveEap(@ApiIgnore EapDto dto) {
        return eapService.saveEap(dto);
    }


    @DeleteMapping("deleteEap")
    @ApiOperation("根据ID删除EAP(最外层)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "对象id", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult deleteEap(@ApiIgnore EapDto dto) {
        return eapService.deleteEap(dto);
    }


    @GetMapping("findPageEap")
    @ApiOperation("分页查询EAP(最外层)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "policyName", value = "policyName模糊查询", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "policyNumber", value = "policyNumber模糊查询", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "benefit", value = "benefit模糊查询", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "0/1,查询所有传null", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始日期,格式:yyyy-MM-dd", required = false, dataType = "date", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束日期,格式:yyyy-MM-dd", required = false, dataType = "date", paramType = "query"),
            @ApiImplicitParam(name = "orderByStr",
                    value = "(默认传：t1.created_on descend),(左到右依次:t3.name,t3.policy_no,t3.type,t4.name,t1.status,t2.user_fullname,t1.created_on)",
                    required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult<PageInfo<EapPageQueryVo>, Object> findPageEap(@ApiIgnore EapDto dto) {
        return eapService.findPageEap(dto);
    }

    @PutMapping("updateEapStatus")
    @ApiOperation("根据ID修改EAP状态(最外层)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "对象id", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态：0-禁用，1-启用", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult updateEapStatus(EapDto dto) {
        return eapService.updateEapStatus(dto);
    }

    @PostMapping("saveEapBenefit")
    @ApiOperation("保存EAPBenefit")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "主键ID/修改必传", required = false, dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "eapId", value = "eapId", required = true, dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "startDate", value = "startDate", required = true, dataType = "date", paramType = "query"),
//            @ApiImplicitParam(name = "endDate", value = "endDate", required = false, dataType = "date", paramType = "query"),
//            @ApiImplicitParam(name = "specialistCompanyId", value = "页面上显示(Specialist panel)", required = false, dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "drugExclusionListId", value = "页面上显示(Drug exclusion list)", required = false, dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "diagnosisExclusionListId", value = "页面上显示(Diagnosis exclusion list)", required = false, dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "medicalServiceExclusionListId", value = "页面上显示(Medical services exclusion list)", required = false, dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "onboardingScreensId", value = "页面上显示(Onboarding screens)", required = false, dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "monthlyAccessMinutes", value = "每月访问分钟数", required = true, dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "patientAccess", value = "1:unlimited;2:capped at monthly access", required = true, dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "remainMonthlyAccess", value = "是否转接到下个月", required = true, dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "doctorType", value = "1:GP 2:SP", required = true, dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "companyId", value = "companyId", required = true, dataType = "string", paramType = "query"),
//    })
    public ResponseResult saveEapBenefit(@RequestBody EapBenefitDto dto) throws ParseException {
        return eapService.saveEapBenefit(dto);
    }

    @PutMapping("updateEapBenefitStatus")
    @ApiOperation("根据ID修改EAPBenefit状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "对象id", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态：0-禁用，1-启用", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult updateEapBenefitStatus(EapBenefitDto dto) {
        return eapService.updateEapBenefitStatus(dto);
    }

    @DeleteMapping("deleteEapBenefit")
    @ApiOperation("根据ID删除EapBenefit")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "对象id", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult deleteEapBenefit(@ApiIgnore EapBenefitDto dto) {
        return eapService.deleteEapBenefit(dto);
    }

    @GetMapping("findListEapBenefit")
    @ApiOperation("根据eapId查询EapBenefit列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "eapId", value = "当前选择的这条eap的id", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult<List<EapBenefitListVo>, Object> findListEapBenefit(@ApiIgnore EapBenefitDto dto) {
        return eapService.findListEapBenefit(dto);
    }

    @GetMapping("findEapBenefitDetail")
    @ApiOperation("根据EapBenefitId查询EapBenefit详情(最里层的详情)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "当前EapBenefitId", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult<EapBenefitDetailVo, Object> findEapBenefitDetail(@ApiIgnore EapBenefitDto dto) {
        return eapService.findEapBenefitDetail(dto);
    }

    //todo: Usage&Limit  这里暂时做不了
    //Consultation list调用问诊通用分页接口
    //Appointment list - 调用辉哥那边的预约接口

    @PostMapping("saveEapBenefitService")
    @ApiOperation("保存EAPBenefitServiceList(点击Benefits详情最下面的ServiceList的添加/编辑)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "对象id/修改必传", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "benefitId", value = "benefitId", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "serviceType", value = "1-Critical incident response(CIP),2-Work life support/employee assistance coaching,3-mental wellness workshop/seminars/wellness talks", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "subCategory", value = "subCategory", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "date", value = "date", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "detuctType", value = "0:上月转接;1:扣除这月", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "minutes", value = "minutes", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult saveEapBenefitService(@ApiIgnore EapBenefitServiceDto dto) {
        return eapService.saveEapBenefitService(dto);
    }


    @DeleteMapping("deleteEapBenefitService")
    @ApiOperation("根据ID删除EapBenefitService")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "对象id", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult deleteEapBenefitService(@ApiIgnore EapBenefitServiceDto dto) {
        return eapService.deleteEapBenefitService(dto);
    }

    @GetMapping("findPageEapBenefitService")
    @ApiOperation("根据benefitId分页查询EapBenefitService")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "benefitId", value = "benefitId", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult<PageInfo<EapBenefitServicePageQueryVo>, Object> findPageEapBenefitService(@ApiIgnore EapBenefitServiceDto dto) {
        return eapService.findPageEapBenefitService(dto);
    }

    @GetMapping("findPageMemberPatientEmployees")
    @ApiOperation("详细最下面的(Member/Patient/Employees)分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "传eapId值", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult<PageInfo<MemberPatientEmployeesPageQueryVo>, Object> findPageMemberPatientEmployees(@ApiIgnore EapDto dto) {
        return eapService.findPageMemberPatientEmployees(dto);
    }

    @GetMapping("addManualAdjustment")
    @ApiOperation("详细的(Usage&Limit)Manual adjustment-只能添加不能修改")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "benefitId", value = "benefitId", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "month", value = "页面显示为：Adjustment month,字符串：年-月", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "1:加 2:减", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "value", value = "页面显示为：Minutes", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "reason", value = "reason", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult addManualAdjustment(@ApiIgnore EapBenefitAdjustmentDto dto) {
        return eapService.addManualAdjustment(dto);
    }

    @GetMapping("findEapUsageLimit")
    @ApiOperation("详细的(Usage&Limit)列表查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "benefitId", value = "benefitId", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult<List<EapUsageLimitVo>, Object> findUsageLimit(@ApiIgnore EapDto dto) {
        return eapService.findUsageLimit(dto);
    }

    @GetMapping("findEapUsageLimit/details")
    @ApiOperation("详细的(Usage&Limit)的详情查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "benefitId", value = "benefitId", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "month", value = "年月字符串,示例:2023-10", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult<List<EapUsageLimitDetailsVo>, Object> findUsageLimitDetails(@ApiIgnore EapDto dto) {
        return eapService.findUsageLimitDetails(dto);
    }


}
